//----------------------------------*-C++-*----------------------------------//
/*!
 * \file   Materials.cc
 * \author Jeremy Roberts
 * \date   Jul 16, 2011
 * \brief  Materials member definitions.
 * \note   Copyright (C) 2011 Jeremy Roberts. 
 */
//---------------------------------------------------------------------------//
// $Rev:: 141                                           $:Rev of last commit
// $Author:: j.alyn.roberts@gmail.com                   $:Author of last commit
// $Date:: 2011-09-14 19:28:23 +0000 (Wed, 14 Sep 2011) $:Date of last commit
//---------------------------------------------------------------------------//

#include <iostream>

#include "material/Materials.hh"

namespace slabtran
{

Materials::Materials(int number_materials, std::string name)
 : d_number_materials(number_materials),
   d_adjoint(0),
   d_xs(number_materials)
{
  Require(d_number_materials > 0);
  Require(d_xs.size() == d_number_materials);
}

// Set adjoint
void Materials::set_adjoint(int adjoint)
{
  Require(d_xs.size()); // d_xs must have elements
  Require(adjoint==0 || adjoint==1);
  d_adjoint = adjoint;
  for (int m = 0; m < d_number_materials; m++)
  {
    Require(d_xs[m]); // element can't be null
    d_xs[m]->set_adjoint(adjoint);
  }
}

// Assign cross-section.
void Materials::assign(SP_XS xs, int xs_id)
{
  Require(xs);
  Require(xs_id >= 0 && xs_id < d_number_materials);
  d_xs[xs_id] = xs;
}

// Check whether assigned.
bool Materials::assigned(int xs_id) const
{
  Require(xs_id < d_xs.size());
  if (d_xs[xs_id]) return true;
  return false;
}

void Materials::print() const
{
  // print set details
  std::cout << " working library details: " << std::endl;
  std::cout << "            library name: " << d_name << std::endl;
  std::cout << "     number of materials: " << d_number_materials << std::endl;
  std::cout << std::endl;
  for (int m = 0; m < d_number_materials; m++)
    (get(m)).print();
}


} // end namespace slabtran

//---------------------------------------------------------------------------//
//              end of Materials.cc
//---------------------------------------------------------------------------//
